<?php

	// Make sure we are authenticated
	require_once('scripts/authentication.php');
	
	// Establish a connection to the database
	require_once('scripts/dbconnection.php');
	
	/* Statistics */
	
	// Number of Books
	$result = mysql_fetch_assoc(mysql_query("SELECT COUNT(*) AS no FROM BOOK"));
	$noOfBooks = $result["no"];
	
	// Number of Authors
	$result = mysql_fetch_assoc(mysql_query("SELECT COUNT(*) AS no FROM AUTHOR"));
	$noOfAuthors = $result["no"];
	
	// Number of Subjects
	$result = mysql_fetch_assoc(mysql_query("SELECT COUNT(*) AS no FROM SUBJECTS"));
	$noOfSubjects = $result["no"];

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
		<title>eLibrary Administration</title>
		<link href="style/defaults.css" rel="stylesheet" type="text/css" media="all" />
		<link href="style/elements.css" rel="stylesheet" type="text/css" media="all" />
	</head>
	<body>
		
		<div class="header">
			<h1><a href="index.php">eLibrary</a></h1>
			<h3>Administer your library.</h3>
		</div>
		
		<div class="container">
			<div class="column">
				<p class="firstP">Welcome to eLibrary Administration. From here you can manage the books, authors and subjects in your libary as well as perform maintenance and backup and restore operations.</p>
				<img src="images/book.png" width="200" height="200" />
				<h4>Books</h4>
				<p>eLibrary is designed to manage a large collection of books. You can add, edit and delete books in <a href="book_admin.php">Book Admininistration</a>.</p>
			</div>
			<div class="column">
				<h4>Authors</h4>
				<p>Occasionaly you may want to add or remove authors from the database. You can do this using <a href="author_admin.php">Author Administration</a>.</p>
				<h4>Subjects</h4>
				<p>You can add, edit or remove subjects from eLibrary using <a href="subject_admin.php">Subject Administration</a>. Subjects are used to assist in grouping similar books togethor.</p>
			</div>
			<div class="column">
				
				<div class="darkCol">
					<h5>Statistics</h5>
					<p>No. of Books: <?php echo $noOfBooks; ?></p>
					<p>No. of Authors: <?php echo $noOfAuthors; ?></p>
					<p>No. of Subjects: <?php echo $noOfSubjects; ?></p>
				</div>
				
				<div class="darkCol">
					<h5>Data Administration</h5>
					<p><a href="export.php">Export data</a></p>
					<p><a href="import.php">Import data</a></p>
				</div>
				
				<div class="smallLink"><a href="about.php">About eLibrary</a></div>
				
			</div>
			
			<div class="clear"></div>
		</div>
	</body>
</html>